﻿using Coldairarrow.Business.Base_AutoReplys;
using Coldairarrow.Entity.Base_AutoReplys;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_AutoReplys
{
    [Route("/Base_AutoReplys/[controller]/[action]")]
    public class Base_AutoReplyDetailController : BaseApiController
    {
        #region DI

        public Base_AutoReplyDetailController(IBase_AutoReplyDetailBusiness base_AutoReplyDetailBus)
        {
            _base_AutoReplyDetailBus = base_AutoReplyDetailBus;
        }

        IBase_AutoReplyDetailBusiness _base_AutoReplyDetailBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_AutoReplyDetail>> GetDataList(PageInput<GetMMSearchDTO> input)
        {
            return await _base_AutoReplyDetailBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_AutoReplyDetail> GetTheData(IdInputDTO input)
        {
            return await _base_AutoReplyDetailBus.GetTheDataAsync(input.Id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Base_AutoReplyDetail data)
        {
            data.Deleted = false;
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _base_AutoReplyDetailBus.AddDataAsync(data);
            }
            else
            {
                await _base_AutoReplyDetailBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_AutoReplyDetailBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}